package com.loan.psychicloan.Util;

import android.text.TextUtils;

/**
 * Created by watilion on 2018/1/4 0004.
 */

public class ValidateUtil {
    private static final int PASS_LOW_LIMIT = 6;
    private static final int PASS_HIGH_LIMIT = 12;

    /**
     * 验证手机号码是否合法
     */
    public static boolean validatePhoneNumber(String mobiles) {
        String telRegex = "^((13[0-9])|(15[^4])|(18[0-9])|(17[0-8])|(147,145))\\d{8}$";
        return !TextUtils.isEmpty(mobiles) && mobiles.matches(telRegex);
    }

    /**
     * 验证密码是否合法　６－１６位
     */
    public static boolean validatePass(String password) {
        return password.length() >= PASS_LOW_LIMIT && password.length() <= PASS_HIGH_LIMIT;
    }


    /**
     * 验证身份证号码是否合法
     */
    public static boolean validateIDCardNumber(String number) {
        return (number.length() == 15 && number.matches("^\\d{15}"))
                || (number.length() == 18 && (number.matches("^\\d{17}[x,X,\\d]")));
    }


    /**
     * 判断是不是英文字母
     */
    public static boolean isECharacter(String codePoint) {
        return codePoint.matches("^[A-Za-z]$");
    }
}

